package fr.gdi.android.news;

import java.util.List;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;

public class FeedAdapter extends ArrayAdapter<FeedDescription>
{
    
    public FeedAdapter(Context context, List<FeedDescription> feeds)
    {
        super(context, R.layout.news_widget_configuration_item, android.R.id.text1, feeds);
    }
    
    @Override
    public View getView(int position, View convertView, ViewGroup parent)
    {
        View v = super.getView(position, convertView, parent);
        ImageView iv = (ImageView) v.findViewById(R.id.icon);
        
        if (getCount() <= 1)
        {
            // no feed
            iv.setVisibility(View.GONE);
        }
        else
        {
            if (position < getCount() - 1)
            {
                iv.setVisibility(View.VISIBLE);
                iv.setImageResource(R.drawable.ic_mp_move);
            }
            else
            {
                iv.setVisibility(View.GONE);
            }
        }
        return v;
    }
    
}